package com.mapull.map;

import com.mapull.clone.Address;

import java.util.HashMap;

/**
 * @author mapull
 */
public class CustomerMap {

    public static void main(String[] args) {
//        cosKey();
//        findCode();
        modKey();
    }
    private static void cosKey(){
        HashMap<Coordinate, Address> map = new HashMap<>();
        Coordinate cod = new Coordinate(1, 2);
        Coordinate cod2 = new Coordinate(2, 1);
        map.put(cod, new Address());
        map.put(cod2, new Address());
        System.out.println(map.size());
    }

    private static void modKey(){
        HashMap<Coordinate, Address> map = new HashMap<>();
        Coordinate cod = new Coordinate(1, 2);
        map.put(cod, new Address());
        System.out.println("修改前 " + map.get(cod));

        // 修改坐标值
        cod.setY(5);
        System.out.println("修改后 " + map.get(cod));
        System.out.println("修改后 " + map);
    }

    private static void findCode(){
        int k = 0;
        for(int i = 0; i <10000; i++){
            for (int j = 0 ; j <10000; j++){
                k++;
                Coordinate cod = new Coordinate(i, j);
                Coordinate cod1 = new Coordinate(j, i);
                if(cod.hashCode() == cod1.hashCode() && i != j){
                    System.out.println("i " + i + " j " + j);
                }
            }
        }
        System.out.println(k);
    }
}
